<?php
namespace Android\Controller;
use Think\Controller;
class MessageController extends Controller {
    //信息添加
    public function find(){
        $info=M('Message');
        $user_id=$_POST['user_id'];
        $array=[];

        //获取收藏作者的信息
        $authorinfo=$info->join('user us on follow.author_id=us.user_id')->where("follow.user_id=$user_id")->field('us.nickname,head_img')->select();
        //收藏的店铺的信息
        $shopinfo=$info->join('shop sh on follow.shop_id=sh.shop_id')->field('sh.shop_name,sh.shop_id,sh.shop_logo,sh.intro')->select();
        $shop=D('shop');
        foreach ($shopinfo as $key => $value) {
            $shopid=$value['shop_id'];
            $infooo= $shop->join('activity ac on ac.shop_id=shop.shop_id')->field('act_id,theme')->where('shop.shop_id='. $shopid)->order('gene_time')->limit(1)->find();
            $shopinfo[$key][]=$infooo;
        }
        $array[]= $shopinfo;
        $array[]=$authorinfo;
        echo json_encode($array);
    }
    //头部重要通知
    public function Message(){
        $user_id=$_GET['user_id'];
        //个人聊天和团体聊天
        $message= D('Message');
        $message-> Message($user_id);
    }
}